
#include "MsnDef.h"

#include "../resource/xpm/contact_online.xpm"
#include "../resource/xpm/contact_busy.xpm"
#include "../resource/xpm/contact_away.xpm"
#include "../resource/xpm/contact_offline.xpm"
#include "../resource/xpm/contact_blocked.xpm"
#include "../resource/xpm/contact_newmsg.xpm"
#include "../resource/xpm/contact_multi.xpm"
#include "../resource/xpm/group_close.xpm"
#include "../resource/xpm/group_open.xpm"



int MsnDef::MSN_FILE_TRANSFER_PORT = 6891;

int MsnDef::MSN_MESSAGE_MAX_LENGTH = 1664;

int MsnDef::STATUS_COUNT = 8;

wxString MsnDef::STATUS_DESC_ARRAY[] = {_T("")};
/*
	{
		_("Online"),
		_("Busy"),
		_("Idle"),
		_("Be right back"),
		_("Away"),
		_("On the phone"),
		_("Out to lunch"),
		_("Hidden")
	};
*/

wxString MsnDef::STATUS_CODE_ARRAY[] =
{
    _T("NLN"),
    _T("BSY"),
    _T("IDL"),
    _T("BRB"),
    _T("AWY"),
    _T("PHN"),
    _T("LUN"),
    _T("HDN")
};

wxImageList MsnDef::ICON_LIST(16, 16); 

void MsnDef::InitIconList()
{
	ICON_LIST.RemoveAll();
	ICON_LIST.Add(wxBitmap(contact_online_xpm));
	ICON_LIST.Add(wxBitmap(contact_busy_xpm));
	ICON_LIST.Add(wxBitmap(contact_away_xpm));
	ICON_LIST.Add(wxBitmap(contact_offline_xpm));
	ICON_LIST.Add(wxBitmap(contact_blocked_xpm));
	ICON_LIST.Add(wxBitmap(contact_newmsg_xpm));
	ICON_LIST.Add(wxBitmap(contact_multi_xpm));
	ICON_LIST.Add(wxBitmap(group_close_xpm));
	ICON_LIST.Add(wxBitmap(group_open_xpm));
/*    
	ICON_LIST.Add(wxBitmap(_T("images/contact_online.gif"), wxBITMAP_TYPE_GIF));
	ICON_LIST.Add(wxBitmap(_T("images/contact_busy.gif"), wxBITMAP_TYPE_GIF));
    ICON_LIST.Add(wxBitmap(_T("images/contact_away.gif"), wxBITMAP_TYPE_GIF));
    ICON_LIST.Add(wxBitmap(_T("images/contact_offline.gif"), wxBITMAP_TYPE_GIF));
	ICON_LIST.Add(wxBitmap(_T("images/contact_blocked.gif"), wxBITMAP_TYPE_GIF));
	ICON_LIST.Add(wxBitmap(_T("images/contact_newmsg.gif"), wxBITMAP_TYPE_GIF));
    ICON_LIST.Add(wxBitmap(_T("images/group_close.gif"), wxBITMAP_TYPE_GIF));
    ICON_LIST.Add(wxBitmap(_T("images/group_open.gif"), wxBITMAP_TYPE_GIF));
*/
}

void MsnDef::InitText()
{
	STATUS_DESC_ARRAY[0] =_("Online");
	STATUS_DESC_ARRAY[1] =_("Busy");
	STATUS_DESC_ARRAY[2] =_("Idle");
	STATUS_DESC_ARRAY[3] =_("Be right back");
	STATUS_DESC_ARRAY[4] =_("Away");
	STATUS_DESC_ARRAY[5] =_("On the phone");
	STATUS_DESC_ARRAY[6] =_("Out to lunch");
	STATUS_DESC_ARRAY[7] =_("Hidden");
}


wxString MsnDef::GetStatusDesc(const wxString& code)
{
    int i;
    for(i=0; i<STATUS_COUNT; i++){
       if(STATUS_CODE_ARRAY[i].IsSameAs(code))
            return STATUS_DESC_ARRAY[i];
    }

    return _("Offline");
}

int MsnDef::GetStatusIndex(const wxString& code)
{
    int i;
    for(i=0; i<STATUS_COUNT; i++){
       if(STATUS_CODE_ARRAY[i].IsSameAs(code))
            return i;
    }

    return -1;
}

int MsnDef::GetStatusIconIndex(const wxString& code)
{
     if(code.IsSameAs(_T("NLN")))
        return ICON_CONTACT_ONLINE;
     else if(code.IsSameAs(_T("BSY")))
        return ICON_CONTACT_BUSY;
     else if(code.IsSameAs(_T("AWY")))
        return ICON_CONTACT_AWAY;
     else if(code.IsSameAs(_T("IDL")))
        return ICON_CONTACT_AWAY;
     else if(code.IsSameAs(_T("PHN")))
        return ICON_CONTACT_AWAY;
     else if(code.IsSameAs(_T("LUN")))
        return ICON_CONTACT_AWAY;
     else if(code.IsSameAs(_T("BRB")))
        return ICON_CONTACT_AWAY;
	 else if(code.IsSameAs(_T("MSG")))
        return ICON_CONTACT_NEWMSG;
	 else if(code.IsSameAs(_T("BLK")))
        return ICON_CONTACT_BLOCKED;
     else
        return ICON_CONTACT_OFFLINE;
}

wxString MsnDef::GetStatusIconFile(const wxString& code)
{
     if(code.IsSameAs(_T("NLN")))
        return _T("images/contact_online.gif");
     else if(code.IsSameAs(_T("BSY")))
        return _T("images/contact_busy.gif");
     else if(code.IsSameAs(_T("AWY")))
        return _T("images/contact_away.gif");
     else if(code.IsSameAs(_T("IDL")))
        return _T("images/contact_away.gif");
     else if(code.IsSameAs(_T("PHN")))
        return _T("images/contact_away.gif");
     else if(code.IsSameAs(_T("LUN")))
        return _T("images/contact_away.gif");
     else
        return _T("images/contact_offline.gif");
}

int MsnDef::GetListCode(const wxString& listType)
{
	if(listType.IsSameAs(_T("FL"))) return FORWARD;
	if(listType.IsSameAs(_T("AL"))) return ALLOWED;
	if(listType.IsSameAs(_T("BL"))) return BLOCKED;
	if(listType.IsSameAs(_T("RL"))) return REVERSED;
	return 0;
}

/*
P2P flag

The flags field in binary header can take the following values:

    * 0x0: no flags specified
    * 0x1: chunk out-of-order
    * 0x2: acknowledgement
    * 0x4: there is a pending invite
    * 0x8: error on the binary level
    * 0x20: display picture/custom emoticon data
    * 0x01000030: file transfer data 

*/

